from Products.KnowledgeEngine.KERL.Operators import *
from Products.KnowledgeEngine.KERL.KERLExceptions import *

class Token(KERLObject):
    
    _implements = KERLObject._implements + ("Token",)
    
    __allow_access_to_unprotected_subobjects__ = 1
        
    operators = {

    }

    def getObject(self):
        return self.object
    
    def __init__(self, object, namespace):
        """ Token wraps this object """
        
        self.object    = object
        self.namespace = namespace        
        
    def findOperator(self, operator):
        """ Finds the relevant operator """
         
        try:
            return self.operators[ operator ]
        except KeyError:
            raise InvalidKerlOperator, \
                  "Cannot find operator '%s' for '%s'" % (operator, self.toEnglish())
    
    def toEnglish(self):
        """ Compiles this token into english """
        
        raise "NotImplemented", self.__class__.__name__ + "::toEnglish"
    
    def toSQL(self):
        """ Compiles this token into english """
        
        raise "NotImplemented", self.__class__.__name__ + "::toSQL"
    
    def toJavascript(self):
        """ Compiles this token into english """
        
        raise "NotImplemented", self.__class__.__name__ + "::toJavascript"
    
    def toKERL(self):
        """ Compiles this token into english """
        
        raise "NotImplemented", self.__class__.__name__ + "::toKERL"    
    
  